package cn.itcast.crm.listener;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

import cn.itcast.crm.po.GoodsTpye;
import cn.itcast.crm.po.User;
import cn.itcast.crm.utils.CacheUtils;
import cn.itcast.crm.utils.CacheUtils.CacheData;

@Service
public class PointRateListener implements ApplicationListener<ContextRefreshedEvent> {
	
	private static final Logger log = Logger.getLogger(PointRateListener.class);

	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent arg0) {
		log.debug("CacheUtils 开始执行");
		//1获取缓存类
		CacheUtils cacheUtils = CacheUtils.getCacheUtils();
		//创建存储用户信息集合 ArrayList
		ArrayList<User> userList = new ArrayList<>();
		//ArrayList 添加用户信息
		userList.add(new User("admin","000000","13213223382"));
		userList.add(new User("wangxiaona","000000","13213223382"));
		//缓存添加用户集合信息
		cacheUtils.put("userList", userList);
		
		//2添加商品种类
		ArrayList<GoodsTpye> goodsList = new ArrayList<>();
		goodsList.add(new GoodsTpye("001","水果类","2021-01-02"));
		goodsList.add(new GoodsTpye("002","办公类","2021-01-02"));
		goodsList.add(new GoodsTpye("003","刀具类","2021-01-03"));
		goodsList.add(new GoodsTpye("004","衣服类","2021-01-04"));
		goodsList.add(new GoodsTpye("005","棉被类","2021-01-05"));
		cacheUtils.put("goodsList", goodsList);
		log.debug("CacheUtils 开始结束");
	}

}